package com.easyui.DB;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * 连接数据库
 * @author Administrator
 *
 */
public class ConnectDB {
	public static Connection getConnection() {
		String driver = "com.mysql.jdbc.Driver";
		String url = "jdbc:mysql://localhost:3306/pms";
		String user = "root";
        String password = "123456";
		
		Connection conn = null;
		try {
			Class.forName(driver);
			conn = DriverManager.getConnection(url, user, password);
			System.out.println("连接数据库成功！\n");
		} catch (ClassNotFoundException e) {
			System.out.println("加载驱动出错，请查看是否引入驱动，详情如下：\n");
			e.printStackTrace();
		} catch (SQLException e) {
			System.out.println("连接数据库出错，请查看连接地址/用户名/密码是否出错，详情如下：\n");
			e.printStackTrace();
		}
		
		return conn;	
	}
}
